@extends('admin._layouts.default')

@section('main')

      <div class="row-fluid ">
        <div class="span12 box gradient ">
      <div class="title">
            <div class="row-fluid">
                <h3>
                  <i class="fa fa-shopping-cart"></i> 积分配置列表
                </h3>
            </div>
        </div><!-- End .title -->
        <div class="content min_h500">

            <table id="datatable_in" class="responsive table table-striped" style="width:100%;margin-bottom:0; ">
              <thead>
               <tr>
                 <th width="80">
                   描述
                  </th>
                  <th width="160">
                    总部建议积分
                  </th>
                  <th width="160">
                    本城市积分
                  </th>
                  <th width="160">
                    修改
                  </th>
               </tr>
              </thead>
              <tbody>
              @foreach($pointconfigs as $pointconfig)
               <tr>
                  <td>
                  {{ $pointconfig->dec }}
                  </td>
                 <td id="count_{{ $pointconfig->id }}">{{ $pointconfig->count }}</td>
                 <td id="count_{{ $pointconfig->id }}">{{ $new_data[$pointconfig->id]['new_point'] }}</td>

                 <td id="button_{{ $pointconfig->id }}">
                 <select id="select_{{ $pointconfig->id }}">
                     <option @if($new_data[$pointconfig->id]['percent'] == '1.5') selected @endif value="1.5">150%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '1.4') selected @endif value="1.4">140%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '1.3') selected @endif value="1.3">130%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '1.2') selected @endif value="1.2">120%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '1.1') selected @endif value="1.1">110%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '1' || $new_data[$pointconfig->id]['percent'] == '') selected @endif value="1">100%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '0.9') selected @endif value="0.9">90%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '0.8') selected @endif value="0.8">80%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '0.7') selected @endif value="0.7">70%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '0.6') selected @endif value="0.6">60%</option>
                     <option @if($new_data[$pointconfig->id]['percent'] == '0.5') selected @endif value="0.5">50%</option>
                 </select>
                 <a href="javascript:void (0)" onclick="change_config({{ $pointconfig->id }})"  class="btn btn-info btn-mini mg5"><i class="fa fa-cog"></i> 修改</a>
                  </td>

               </tr>
               @endforeach

               </tbody>
            </table>


            </div>
        </div>
        <!-- End box -->
      </div>

@stop




@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/full-calendar/fullcalendar.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.peity.min.js') }}"></script>
<script type="text/javascript" language="javascript" src="{{ URL::asset('ad/js/plugins/datatables/js/jquery.dataTables.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/flot/jquery.flot.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.uniform.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/raphael.2.1.0.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/justgage.1.0.1.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/scripts.js') }}"></script>


    <script type="text/javascript" charset="utf-8">
    // Datatables
    $(document).ready(function() {
      var dontSort = [];
                $('#datatable_city thead th').each( function () {
                    if ( $(this).hasClass( 'no_sort' )) {
                        dontSort.push( { "bSortable": false } );
                    } else {
                        dontSort.push( null );
                    }
      } );
      $('#datatable_city').dataTable( {
        "sDom": "<'row table_top_bar'<'row-fluid'>'<'to_hide_phone'>'f'<'>r>t<'row'>",
         "sDom": "<'row table_top_bar'<'row-fluid'<'to_hide_phone' f>>><'row'>",
         "aaSorting": [[ 1, "asc" ]],
        "bPaginate": false,
        "bJQueryUI": false,
        "aoColumns": dontSort

      } );
      $.extend( $.fn.dataTableExt.oStdClasses, {
        "s`": "dataTables_wrapper form-inline"
      } );
    } );
    </script>
    <script>
    function change_config(id){
        var per = $('#select_'+id).val();
        $.post("{{ route('admin.pointconfigs.ajax') }}",{id : id, per : per , type : 'city'},function(data){
            if(data == 1){
               location.reload()
            }else{
                alert('保存失败');
            }
        })
    }
    </script>
@stop
